package com.itheima.manager;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.itheima.common.PageResult;
import com.itheima.domain.PmsProduct;
import com.itheima.domain.PmsProductAttribute;
import com.itheima.domain.PmsProductCategory;
import com.itheima.service.PmsProductAttributeService;
import com.itheima.service.PmsProductCategoryService;
import com.itheima.service.PmsProductService;
import com.itheima.vo.ProductAttrInfo;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

@Component
public class PmsProductAttributeManager {
    @DubboReference
    PmsProductAttributeService pmsProductAttributeService;

    public List<ProductAttrInfo> attrInfo(Integer productCategoryId) {
       return pmsProductAttributeService.productAttrInfos(productCategoryId);
    }

    public PageResult list(Integer cid, Integer type, Integer pageSize, Integer pageNum) {
        return pmsProductAttributeService.listByCid(cid,type,pageSize,pageNum);
    }

    public PmsProductAttribute getById(Integer id) {
        return pmsProductAttributeService.getById(id);
    }

    public void creat(PmsProductAttribute pmsProductAttribute) {
        pmsProductAttributeService.save(pmsProductAttribute);
    }

    public void delete(List<Integer> ids) {
        pmsProductAttributeService.removeByIds(ids);
    }

    public void update(Integer id, PmsProductAttribute productAttribute) {
        productAttribute.setId((long) id);
        pmsProductAttributeService.updateById(productAttribute);
    }
}
